#ifndef AVALON_CLIENTCHANNELMIXIN_HPP
#define AVALON_CLIENTCHANNELMIXIN_HPP
#include "Avalon/IO/ConnectionState.hpp"
#include "Avalon/ServiceLocator/DirectoryEntry.hpp"
#include "Avalon/Services/Services.hpp"
#include "Avalon/Threading/AsyncTaskQueue.hpp"

namespace Avalon {
namespace Services {

  /*! \class ClientChannelMixin
   *  \brief Contains common functionality used by clients connected to an
   *         Avalon service.
   *  \author Kamal Mansouri <kranar@hotmail.com>
   */
  class ClientChannelMixin {
    public:

      //! Constructs a ClientChannelMixin.
      ClientChannelMixin();

      virtual ~ClientChannelMixin();

      //! Returns <code>true</code> iff the Channel logged in.
      bool IsLoggedIn() const;

      //! Returns the Channel's Account.
      const ServiceLocator::DirectoryEntry::Tag& GetAccount() const;

      //! Sets the Channel's Account, establishing it as having logged in.
      /*!
        \param account The Account Tag to associate with this Channel.
      */
      void SetAccount(const ServiceLocator::DirectoryEntry::Tag& account);

      //! Returns the state of this Channel's Connection.
      IO::ConnectionState& GetConnectionState();

      //! Returns the Task queue.
      Threading::AsyncTaskQueue& GetTaskQueue();

    protected:

      //! The Account used to login.
      ServiceLocator::DirectoryEntry::Tag m_account;

      //! The state of the Channel's Connection.
      IO::ConnectionState m_connectionState;

      //! Stores the pending tasks.
      Threading::AsyncTaskQueue m_taskQueue;
  };
}
}

#endif // AVALON_SERVICECHANNELMIXIN_HPP
